package com.factory.model.factory;

import com.factory.model.entity.Fruits;

/**
 * 实例工厂
 *
 * @author zyangb
 */
public class FruitsFactory extends AbstractFruitsFactory {
    /**
     * 工厂生产果汁
     *
     * @param c
     * @param <T>
     * @return
     */
    @Override
    public <T extends Fruits> T createFruitJuice(Class<T> c) {
        Fruits fruits = null;
        try {
            //使用反射创建对象
            fruits = (T) Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("工厂生产果汁错误");
        }
        return (T) fruits;

    }
}
